/**
 * 互联网电子病历
 */
import React from 'react'
import { Form, Select, Row, Col, Radio, message, DatePicker, Icon, Input, Modal, Tree, List, Button, Card, Table, Popconfirm, Divider } from 'antd';
import { $http } from '../../../containers/config/https';
import RangeDatePicker from 'components/rangePicker/index';
import store from 'store';
import CommonPagination from 'components/pagination/index';
import { Util, dayFormat } from 'tools/index';
import './style.less'
import { $loadTemplate } from '../../lodop/Common/Print.js';
import moment from 'moment';
import RecordCompoent from './RecordCompoent'
import { getLodop } from '../../lodop/Common/LodopFuncs.js';
import { element } from 'prop-types';
import { connect } from 'socket.io-client';


const { Option } = Select;
var leftImg = require('./images/left.png');
var rightImg = require('./images/right.png');
const { DirectoryTree } = Tree;
const { TextArea } = Input;
const { Search } = Input;
let user = {}
let patientData = {}

const layout = {
    labelCol: { span: 4 },
    wrapperCol: { span: 20 },
};
const tailLayout = {
    wrapperCol: { offset: 8, span: 16 },
};
class MedicalRecord extends React.Component {
    //InfectiousDictionary
    constructor(props) {
        super(props);
        var date = new Date()
        patientData = sessionStorage.patientData ? JSON.parse(sessionStorage.patientData) : {};
        user = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {};
        patientData = JSON.parse(sessionStorage.getItem('patientData'));
        this.state = {
            recordTemplate: [],
            recordArr: [],
            selectedKeys1: [],  //配置的模板ID
            basicData: [],
            baseInfo: {},
            diagnoseObj: [],
            orderPresc: [],
            showButton: true,
            detailMessage: {},
            imageSource: [],
            visible: false,
            SS: 1,
            i: 0,
            S: 1,
            firstIndex: 0,
            f: 0,
            imgPath: "",
            TemplateList: [],
            tabIndex: 0,
            findDesc: "",
            templateTypeList: [],
            showTemplate: false,
            historyList: [],
            historyTemplateIndex: 0,
            locTemplateIndex: 0,
            reciverTemplate: [],
            locTemplate: [],
            locTypeID: "",
            searchValue: "",
            diagnoseTempObj: [],
            orderTempPresc: [],
            catName: "",
            catID: "",
            defaultIEMRMoudleID: "",
            selectedKeys: [], //树选择的模板ID
            medicalRecordShow: "",
            printShow: "",
            writeMust: "",
            updateFlag: "N",
            visibleMedical: false,
            visibleSave: false,
            nameInput: undefined, // 别名
            tableData: [],
            RowId: "",
            currentElement: '',
            content1: ''
            // expandedKeys:['0'],
        };
        this.columns = [
            {
                title: '名称',
                dataIndex: 'title',
                width: '300px',
                key: "title"
            }

        ];
    }

    componentDidMount() {
        this.props.onRef(this)
        //this.props.onRef(this);
        this.recordTemplate()
        this.loadVideoChatMsg()
        //this.selectHistoryTemplate()
        this.selectLocTemplate()
        this.loadEndReceiveOfDisableBtn()
    }


    loadEndReceiveOfDisableBtn() {
        var params = {
            params: [{
                admID: patientData ? patientData.admID : '',
                hospID: user.hospID,
                userID: user.userID,
                locID: user.locID,
            }]
        }
        $http.post('urlDeault', this, {
            code: "03100124",
            data: params,
            success: (res) => {
                if (res.errorCode == '0') {
                    this.setState({
                        disBtn: res.result
                    })
                }
            }
        })
    }

    selectLocTemplate = () => {
        //patientData.admID
        let data = {
            params: [{
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020008",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    this.setState({
                        locTemplate: res.result.data,
                        locTypeID: res.result.data[0].id
                    }, () => {
                        this.selectLocTemplateDateil()
                    })
                }
            }
        })
    }

    selectLocTemplateDateil = (value) => {
        //patientData.admID
        let data = {
            params: [{
                IEMRMoudleDesc: value ? value : "",
                power: "mould"
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020010",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    if (res.result.data && res.result.data.length > 0) {
                        var templateTypeList = res.result.data
                        var value = ""
                        var selectedKeys = []
                        templateTypeList.forEach(element => {
                            if (this.state.locTypeID == element.id) {
                                value = element.moudleItem.length > 0 ? element.moudleItem[0].IEMRMoudleID : ''

                                this.selectTemplateByIEMRMoudleID(value)
                            }
                        });
                    }
                    selectedKeys.push("" + value + "")
                    this.setState({
                        medicalRecordShow: res.result.medicalRecordShow,
                        writeMust: res.result.writeMust,
                        printShow: res.result.printShow,
                        templateTypeList: res.result.data,
                        defaultIEMRMoudleID: value,
                        selectedKeys: selectedKeys,
                    }, () => {

                    })
                }
            }
        })
    }


    selectHistoryTemplate = () => {
        let { TemplateList, selectedKeys } = this.state
        //patientData.admID
        let data = {
            params: [{
                patID: patientData.patID,
                IEMRTemplateID: selectedKeys[0]
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020006",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    var historyTemplateIndex = 0
                    var admID = ""
                    if (res.result.data && res.result.data.length > 0) {
                        admID = res.result.data[historyTemplateIndex].admID
                    }
                    this.setState({
                        historyList: res.result.data
                    }, () => {
                        if (admID != "") {
                            this.templateBasic(admID)
                            this.patRecordData(admID)
                        }
                    })
                }
            }
        })
    }


    loadVideoChatMsg() {
        var patientData = sessionStorage.patientData ? JSON.parse(sessionStorage.patientData) : {};
        var params = {
            params: [{
                admID: patientData.admID,
            }]
        }
        $http.post('urlDeault', this, {
            code: "03100070",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    var image = []
                    var source = []
                    if (!Util.isEmpty(res.result) && !Util.isEmpty(res.result.imageAddress)) {
                        image = (res.result.imageAddress).split('&');
                    }
                    if (!Util.isEmpty(image)) {
                        for (var i = 0; i < image.length; i++) {
                            if (!Util.isEmpty(image[i])) {
                                source.push(image[i])
                            }
                        }
                    }
                    this.setState({
                        detailMessage: res.result,
                        imageSource: source
                    })
                }
            }
        });
    }

    loadImageMsg() {
        var imageAddress = []
        //图片截取
        if (!Util.isEmpty(this.state.detailMessage) && !Util.isEmpty(this.state.detailMessage.imageAddress)) {
            var image = (this.state.detailMessage.imageAddress).split('&');
            image && image.map((item, index) => {
                if (!Util.isEmpty(item)) {
                    imageAddress.push(<img scr={item} key={index} className='img-bgd-style' style={{
                        width: '150px', height: 150, background: `url(${item})`,
                        cursor: 'pointer'
                    }} alt=''
                        onClick={this.handleShowModal.bind(this, item, index)} />)
                }
            })
        }
        return imageAddress
    }

    handleShowModal = (imgPath, index) => {
        this.setState({ visible: true, imgPath, firstIndex: index, f: index })
    }


    handleClose = () => {
        this.setState({
            visible: false, rotaRight: 0, SS: 1,
            i: 0,
            S: 1,
            f: 0
        })
    }
    //顺时针旋转
    rotateright = () => {
        this.setState({ rotaRight: this.state.rotaRight + 90 })
        this.refs.imgstyle.style.transform = "translate(-50% ,0%) rotate(" + this.state.rotaRight + "deg) scale(" + this.state.SS + "," + this.state.SS + ")"
    }

    //放大
    showbig = () => {
        if (this.state.i >= 0) {
            this.setState({ S: this.state.S + 1, i: this.state.i + 1, SS: 1 * (this.state.S + 1) })
        } else {
            this.setState({ S: this.state.S - 1, i: this.state.i + 1, SS: 1 / (this.state.S - 1) })
        }
        this.refs.imgstyle.style.transform = "translate(-50% ,0%) rotate(" + this.state.rotaRight + "deg) scale(" + this.state.SS + "," + this.state.SS + ")"
    }

    //缩小
    showmin = () => {
        if (this.state.i <= 0) {
            this.setState({ S: this.state.S + 1, i: this.state.i - 1, SS: 1 / (this.state.S + 1) })
        } else {
            this.setState({ S: this.state.S - 1, i: this.state.i - 1, SS: 1 * (this.state.S - 1) })
        }
        this.refs.imgstyle.style.transform = "translate(-50% ,0%) rotate(" + this.state.rotaRight + "deg) scale(" + this.state.SS + "," + this.state.SS + ")"
    }

    handleDisableBtn(flag) {
        this.setState({
            disableBtn: flag
        })
    }

    handleShowChangeImgBtn() {
        this.setState({
            showImg: true
        })
    }

    handleHideImgBtn() {
        this.setState({
            showImg: false
        })
    }

    //向左预览
    leftshow = () => {
        if (this.state.f == 0) {
            return
            this.setState({ f: this.state.imageSource.length, R: 0, S: 1, i: 0, SS: 1 })
        } else {
            this.setState({ f: this.state.f - 1, R: 0, S: 1, i: 0, SS: 1 })
        }
        this.refs.imgstyle.setAttribute('src', this.state.imageSource[this.state.f])
        this.setState({})
    }

    //向右预览
    rightshow = () => {
        if (this.state.f == this.state.imageSource.length - 1) {
            return
            this.setState({ f: 0, R: 0, S: 1, i: 0, SS: 1 })
        } else {
            this.setState({ f: this.state.f + 1, R: 0, S: 1, i: 0, SS: 1 })
        }
        this.refs.imgstyle.setAttribute('src', this.state.imageSource[this.state.f])
        this.setState({})
    }

    recordTemplate = () => {
        let { expandedKeys } = this.state
        var patientData = sessionStorage.patientData ? JSON.parse(sessionStorage.patientData) : {};
        let data = {
            params: [{
                admID: patientData.admID
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020001",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    let recordArr = []
                    if (res.result.TemplateList) {
                        recordArr = res.result.TemplateList
                        recordArr.forEach(element => {
                            element.title = element.name
                            element.key = element.id
                            element.isLeaf = true
                        });
                    }
                    var treeData = []
                    var treeObj = {
                        title: '病历',
                        key: '0',
                        children: recordArr
                    }
                    treeData.push(treeObj)
                    this.state.selectedKeys1.push(recordArr[0].id)
                    // expandedKeys.push(recordArr[0].id)
                    this.setState({
                        TemplateList: res.result.TemplateList,
                        recordTemplate: treeData,
                        recordArr: recordArr,
                        // expandedKeys,
                    }, () => {
                        this.templateBasic()
                        //this.selectHistoryTemplate()
                    })

                }
            }
        })
    }

    templateBasic = (admID) => {

        let data = {
            params: [{
                IEMRTemplateID: this.state.selectedKeys1[0],
                admID: admID ? admID : patientData.admID,
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020002",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    if (admID) {
                        this.setState({
                            reciverTemplate: res.result
                        })
                    } else {
                        this.setState({
                            basicData: res.result,
                        }, () => {
                            this.patRecordData()
                        })
                    }

                }
            }
        })
    }

    printRecord = () => {
        let data = {
            params: [{
                IEMRTemplateID: this.state.selectedKeys1[0],
                admID: patientData.admID
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020005",
            data: data,
            success: (res) => {
                if (res.errorCode === '0') {
                    const data = res.result
                    LODOP = getLodop();
                    LODOP.PRINT_INIT('InternetMZEMR');     //打印初始化
                    eval(data);            //执行打印内容 
                }
            }
        })
    }

    patRecordData = (admID) => {

        let data = {
            params: [{
                admID: admID ? admID : (patientData.admID ? patientData.admID : "")
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020004",
            data: data,
            success: (res) => {
                // console.log(res);
                if (+res.errorCode === 0) {
                    if (admID) {
                        this.setState({
                            baseInfo: res.result.baseInfo,
                            diagnoseTempObj: res.result.diagnoseObj,
                            orderTempPresc: res.result.orderPresc,
                        })
                    } else {
                        this.setState({
                            baseInfo: res.result.baseInfo,
                            diagnoseObj: res.result.diagnoseObj,
                            orderPresc: res.result.orderPresc,
                        })
                    }

                }
            }
        })

    }



    saveRecord = (flag) => {
        var detailData = []
        var errorFlag = false
        this.props.form.validateFields((error, values) => {
            Object.keys(error).forEach(function (key) {
                if (key != "templateType" && key != "templateName" && key != "content") {
                    errorFlag = true
                }
            })

            Object.keys(values).forEach(function (key) {

                var keyArr = key.split("ID")
                if (keyArr[1]) {
                    var obj = { IEMRTempElementID: keyArr[1], IEMRTempElementData: values[key] || '' };
                    detailData.push(obj)
                }
            });
        })

        if (errorFlag) {
            return;
        }
        let data = {
            params: [{
                "IEMRTemplateID": this.state.selectedKeys1[0],
                "admID": patientData.admID,
                "patID": patientData.patID,
                "detailData": detailData,
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020003",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    if (flag == "Y") {
                        this.setState({
                            showTemplate: true,
                        })
                    } else {
                        message.success(`保存${res.errorMessage}`)
                    }
                    var { componentRouter } = this.props;
                    componentRouter && componentRouter(false, '4')
                    this.setState({
                        showButton: true,
                    }, () => {
                        this.recordTemplate()
                    })
                }
            }
        })

    }


    onSelect = (data, event) => {
        var selectedKeys = this.state.selectedKeys1
        if (data.id != "") {
            selectedKeys[0] = data.id
            this.setState({
                showButton: true
            }, () => {
                this.templateBasic()
            })
        }
        this.setState({
            selectedKeys: selectedKeys,
        })

    };

    selectTab = (val, flag, e) => {
        this.setState({
            [flag]: val
        })
        if (flag == "historyTemplateIndex") {
            var admID = this.state.historyList[val].admID
            this.templateBasic(admID)
            this.patRecordData(admID)
        }

        if (flag == "locTypeID") {
            var locTypeID = e.target.value
            var templateTypeList = this.state.templateTypeList
            var selectedKeys = []
            var selectedKeysID = ""
            if (templateTypeList && templateTypeList.length > 0) {
                templateTypeList.forEach(element => {
                    if (element.id == locTypeID) {
                        selectedKeysID = element.moudleItem[0].IEMRMoudleID
                    }
                });
            }
            selectedKeys.push("" + selectedKeysID + "")
            this.setState(
                {
                    [flag]: locTypeID,
                    selectedKeys: selectedKeys
                }
                , () => {
                    this.selectTemplateByIEMRMoudleID(selectedKeysID)
                })
        }
        if (flag == "tabIndex" && val == 1) {
            this.selectHistoryTemplate()
        }

        if (flag == "tabIndex" && val == 0) {
            this.selectLocTemplate()
        }



    }

    onExpand = () => {
        // console.log('Trigger Expand');
    };

    showTemplateModal = () => {
        this.saveRecord("Y")

    }

    closeTemplate = () => {
        this.setState({
            showTemplate: false
        })
    }


    selectRecordCat = () => {
        let data = {
            params: [{

            }]
        }
        $http.post('urlDeault', this, {
            code: "10020003",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    if (flag) {
                        this.setState({
                            showTemplate: true,
                        })
                    }
                    this.setState({
                        showButton: true
                    }, () => {
                        this.recordTemplate()
                    })
                }
            }
        })
    }

    saveTemplate = () => {
        this.props.form.validateFields((error, values) => {
            Object.keys(error).forEach(function (key) {
                if (key != "content") {
                    return;
                }
            })
            var startDate = moment(values.haveDate).format("YYYY-MM-DD")
            var endDate = ""
            if (values.notDate && values.notDate != "") {
                endDate = moment(values.notDate).format("YYYY-MM-DD")
            }
            let data = {
                params: [{
                    IEMRTemplateID: this.state.selectedKeys1[0],
                    IEMRMoudleDesc: values.templateName,
                    templetTypeID: values.templateType,
                    IEMRMoudleStartDate: startDate,
                    IEMRMoudleStopDate: endDate,
                    IEMRMouldCataID: values.behaveCat
                }]
            }
            $http.post('urlDeault', this, {
                code: "10020007",
                data: data,
                success: (res) => {
                    if (+res.errorCode === 0) {
                        this.closeTemplate()
                        message.success("保存成功")
                        this.saveTemplateDateil(res.result.IEMRMoudleID)
                        this.props.form.setFieldsValue({ templateType: "", templateName: "" })
                    }
                }
            })

        })
    }




    saveTemplateDateil = (IEMRMoudleID) => {
        var basicData = this.state.basicData
        var recordArr = []
        basicData.forEach(element => {
            var recordObj = {}
            recordObj.IEMRTempElementID = element.IEMRTempElementID
            recordObj.IEMRMoudleElementData = element.IEMRTempElementData ? element.IEMRTempElementData : element.IEMRMoudleElementData
            recordArr.push(recordObj)
        });
        let data = {
            params: [{
                IEMRMoudleID: IEMRMoudleID,
                detailData: recordArr,
            }]
        }
        $http.post('urlDeault', this, {
            code: "10020009",
            data: data,
            success: (res) => {
                // console.log(res);
                if (+res.errorCode === 0) {
                    this.closeTemplate()
                    this.selectLocTemplate()
                }
            }
        })
    }

    exchangeTemplate = (Flag) => {
        var basicData = this.state.basicData
        var reciverTemplate = this.state.reciverTemplate
        basicData.forEach(element => {
            reciverTemplate.forEach(item => {
                if (element.IEMRTempElementCode == item.IEMRTempElementCode)
                    element.IEMRTempElementData = item.IEMRMoudleElementData ? item.IEMRMoudleElementData : item.IEMRTempElementData
            });
        });
        basicData.forEach(element => {
            var code = "ID" + element.IEMRTempElementID
            if (Flag == "Y") {
                this.props.form.setFieldsValue({ [code]: "" })
            } else {
                this.props.form.setFieldsValue({ [code]: element.IEMRTempElementData })
            }

        });

    }

    searchTemplate = (event, value) => {
        var searchValue = event.target.value
        this.selectLocTemplateDateil(searchValue)
    }

    searchTemplatText = (e) => {
        this.setState({
            searchValue: e.target.value
        })
    }

    selectType = (index, flag, value) => {
        this.setState({
            [flag]: index
        }, () => {
            this.selectTemplateByIEMRMoudleID(value)
        })
    }

    selectTemplateByIEMRMoudleID = (value) => {
        if (value != "" && value != undefined) {
            let data = {
                params: [{
                    IEMRMoudleID: value,
                    power: "moudleElement"
                }]
            }
            $http.post('urlDeault', this, {
                code: "10020011",
                data: data,
                success: (res) => {
                    // console.log(res);
                    if (+res.errorCode === 0) {
                        this.setState({
                            reciverTemplate: res.result.data
                        })
                    }
                }
            })
        }

    }

    onSelectDateil = (selectedKeys, e) => {
        this.setState({
            selectedKeys: selectedKeys
        })
        if (e.selectedNodes[0].props.fieldType == "mould") {
            this.selectTemplateByIEMRMoudleID(selectedKeys[0])
        }
    }
    showModal = (elementID, val) => {

        this.setState({
            currentElement: elementID,
            visibleMedical: true,
        }, () => {
            this.handleQuery();
        });
    };

    showModalSave = (elementID, val) => {
        console.log('huih', val)
        this.setState({
            currentElement: elementID,
            visibleSave: true,
        });
    }
    // 搜索条件 -- 别名
    handleNameInput = (e) => {
        this.setState({ nameInput: e.target.value })
    }
    //重置表单
    handleReset = () => {
        // this.props.form.resetFields();
        this.setState({ RowId: '', MedicalInfo: {} })
    }
    //保存到知识库
    handleOkSave = () => {
        let { currentElement } = this.state;
        let tempData = this.props.form.getFieldsValue(['content', 'startDate', 'stopDate', 'ID' + currentElement])
        // console.log('tempData',tempData)
        let data = {
            params: [
                {
                    id: "",
                    title: tempData.content,
                    content: tempData['ID' + currentElement],
                    element: currentElement,  //元素id
                    startDate: tempData.startDate ? moment(tempData.startDate).format('YYYY-MM-DD') : '',
                    stopDate: tempData.stopDate ? moment(tempData.stopDate).format('YYYY-MM-DD') : '',

                }
            ]

        }
        console.log('data', data)
        $http.post('urlADS', this, {
            code: "03100152",
            data: data,
            success: function (res) {
                console.log(res)
                if (+res.errorCode === 0) {
                    // 成功提示
                    message.success('保存成功');
                    //新增或编辑成功重置form表单
                    this.handleReset();
                    this.setState({ MedicalInfo: {} })
                    // 关闭弹框
                    this.onCancel();
                    // this.recordTemplate()


                }
            }
        })
    }
    onCancel = () => {
        this.setState({
            visibleSave: false,
        }, () => {
            this.props.form.setFieldsValue({ content: '' })
        });
    };

    //获取知识库
    handleQuery = () => {
        // this.resetFields();
        let { currentElement } = this.state;
        let data = {
            params: [
                {
                    docID: user.userID,
                    validFlag: true,
                    searchVal: this.state.nameInput,
                    element: currentElement  //元素id

                }
            ]
        }
        $http.post('urlS', this, {
            code: "03100154",
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    this.setState({ tableData: res.result })
                }
            }
        })
    }

    setRowClassName = (record) => {
        return record.id === this.state.RowId ? 'clickRowStyle' : '';
    }
    //从知识库选择
    handleOk = e => {
        const { content1, currentElement } = this.state
        // console.log('handleOk', content1);
        this.props.form.setFieldsValue({
            ['ID' + currentElement]: content1,
            content: ''
        })
        this.setState({
            visibleMedical: false,
            content1: ''
        });
    };

    handleCancel = e => {
        this.setState({
            visibleMedical: false,
            content1: ''
        });
    };


    //点击行事件
    tableClickRow = (record) => {
        const { content } = record
        //给右边的编辑form传值
        return {
            onClick: () => {
                if (this.state.RowId === "") {
                    this.setState({
                        RowId: record.id,
                        MedicalInfo: record,
                        content1: content
                    });
                } else {
                    if (this.state.RowId !== record.id) {
                        this.setState({
                            RowId: record.id,
                            MedicalInfo: record,
                            content1: content
                        });
                    } else {
                        this.setState({
                            RowId: "",
                            MedicalInfo: {},
                        });
                    }
                }

            },
        };
    }


    changeCatName = (value) => {
        console.log(value)
        this.props.form.setFieldsValue()
    }



    updateFlag = () => {
        this.setState({
            updateFlag: "Y"
        })
        var { componentRouter } = this.props;
        componentRouter && componentRouter(true, '4')
    }

    onInput = (e) => {
        this.setState({ content1: e.target.value })

    }

    render() {
        let { nameInput, tableData,
        } = this.state;
        const formItemInput = {
            labelCol: { span: 4 },
            wrapperCol: { span: 20 }
        };
        const formItemDatePicker = {
            labelCol: { span: 8 },
            wrapperCol: { span: 16 }
        }

        var locTypeID = this.state.locTypeID
        var templateTypeListArr = this.state.templateTypeList
        var diagonseStr = ""
        var diagnoseObj = this.state.diagnoseObj
        diagnoseObj.forEach(element => {
            diagonseStr = diagonseStr + element.ICDDesc + ";  "
            if (element.TCMSyndrome) {
                element.TCMSyndrome.forEach(item => {
                    diagonseStr = diagonseStr + item.syndromeDesc + ";  "
                });
            }

        });



        var treeData = []
        var catArr = []
        var behaveCatArr = []
        // 树形结构的变换
        if (templateTypeListArr) {
            templateTypeListArr.forEach(patient => {
                if (locTypeID == patient.id) {
                    var templateListItem = patient.item
                    templateListItem.forEach(element => {
                        if (element.fieldType == "catalog") {
                            element.title = element.IEMRMouldCataDesc,
                                element.key = "a" + element.IEMRMouldCataID
                            if (element.moudleItem && element.moudleItem.length > 0) {
                                element.moudleItem.forEach(item => {
                                    item.title = item.IEMRMoudleDesc,
                                        item.key = item.IEMRMoudleID
                                    item.isLeaf = true
                                    behaveCatArr.push(item.IEMRMoudleID)
                                })
                            }

                            element.children = element.moudleItem
                            treeData.push(element)
                            catArr.push(element)
                        }
                    });
                    var templateList = patient.moudleItem
                    templateList.forEach(element => {
                        if (element.fieldType == "mould") {
                            element.title = element.IEMRMoudleDesc,
                                element.key = element.IEMRMoudleID
                            element.isLeaf = true
                            if (behaveCatArr.indexOf(element.IEMRMoudleID) == -1) {
                                treeData.push(element)
                            }
                        }
                    });
                }



            });
        }

        var templateTypeList = []
        if (this.state.locTemplate) {
            this.state.locTemplate.map((item, index) => {
                templateTypeList.push(
                    <Radio value={item.id} checked={item.id == this.state.locTypeID}>{item.descripts}</Radio>
                )
            })
        }


        var vatRecordArr = []
        catArr.map((item, index) => {
            vatRecordArr.push(
                <Option key={item.IEMRMouldCataID} value={item.IEMRMouldCataID} >
                    {item.IEMRMouldCataDesc}
                </Option>
            )
        })

        var medicalArr = []
        var westMedicalArr = []
        if (this.state.orderPresc && this.state.orderPresc.length > 0) {
            this.state.orderPresc.forEach(element => {
                if (element.prescTypeCode == "CM") {
                    medicalArr.push(element)
                } else {
                    westMedicalArr.push(element)
                }
            });
        }

        //  {item.admDocDesc}  就诊医生
        const { getFieldDecorator } = this.props.form;

        let MedicalInfo = this.state.MedicalInfo ? this.state.MedicalInfo : {};
        return (
            <div className="medicalRecord" style={{ height: '100%', overflow: 'hidden' }}>
                <Row style={{ height: '100%' }}>
                    <Col span={3} style={{ width: '11.5%', height: '100%' }} className="leftBody">
                        <Row style={{ height: '47px', width: '100%' }}>
                            <Col span={12} style={{ border: '1px solid #eeeeee', textAlign: 'center', lineHeight: '47px', color: this.state.tabIndex == 0 ? 'dodgerblue' : '', borderBottom: this.state.tabIndex == 0 ? '1px solid dodgerblue' : '1px solid #eeeeee' }} onClick={this.selectTab.bind(this, 0, "tabIndex")}> 病历模板</Col>
                            <Col span={12} style={{ border: '1px solid #eeeeee', textAlign: 'center', lineHeight: '47px', color: this.state.tabIndex == 1 ? 'dodgerblue' : '', borderBottom: this.state.tabIndex == 1 ? '1px solid dodgerblue' : '1px solid #eeeeee' }} onClick={this.selectTab.bind(this, 1, "tabIndex")}>历史病历</Col>
                        </Row>
                        {this.state.tabIndex == 0 ? (
                            <div style={{ height: 'calc(100vh - 197px)', width: '100%' }}>
                                <Search
                                    enterButton={true}
                                    placeholder="输入模板名称搜索内容"
                                    onSearch={(value) =>
                                        this.selectLocTemplateDateil(value)
                                    }
                                    // style={{ width: 200 }}
                                    onChange={this.searchTemplatText}
                                    value={this.state.searchValue}
                                    onPressEnter={this.searchTemplate}
                                    style={{ width: '100%' }}
                                />
                                <Radio.Group onChange={this.selectTab.bind(this, "", "locTypeID")}>
                                    {templateTypeList}
                                </Radio.Group>
                                <DirectoryTree
                                    className="directoryTree"
                                    defaultExpandAll={true}
                                    treeData={treeData}
                                    // defaultExpandedKeys={expandedKeys}
                                    defaultExpandParent
                                    //expandedKeys={expandedKeys}
                                    onSelect={this.onSelectDateil}
                                    onExpand={this.onExpand}
                                    style={{ height: 'calc(100% - 58px)', width: '100%', overflowY: 'auto' }}
                                    defaultSelectedKeys={this.state.selectedKeys}
                                    selectedKeys={this.state.selectedKeys}
                                />
                            </div>
                        ) : (
                            <div style={{ height: 'calc(100% - 50px)', width: '100%', overflowY: 'auto' }}>
                                {this.state.historyList.map((item, index) => {
                                    return (
                                        <div style={{ height: 'auto', width: '100%', lineHeight: '47px', color: this.state.historyTemplateIndex == index ? 'dodgerblue' : '', background: this.state.historyTemplateIndex == index ? 'rgba(223, 238, 255, 1)' : '', }} onClick={this.selectTab.bind(this, index, "historyTemplateIndex")} >
                                            {item.admDate} / {item.admLocDesc}
                                        </div>
                                    )
                                })}

                            </div>
                        )}

                    </Col>
                    <Col span={4} style={{ height: 'calc(100vh - 148px)', border: '1px solid #eeeeee' }}>
                        <div style={{ height: '49px', border: '1px solid #eeeeee', textAlign: 'center', lineHeight: '47px' }}>模板详情</div>
                        <div style={{ width: '100%', height: ' calc(100% - 87px)', overflowY: 'auto', fontSize: '14px', paddingLeft: '7px', lineHeight: '30px', borderTop: '2px solid #eeeeee' }}>
                            {this.state.reciverTemplate.map((item, index) => {

                                return (
                                    <div>
                                        <div style={{ fontWeight: 'bold', height: '30px', width: '100%' }}>{item.IEMRTempElementDesc}</div>
                                        <div style={{ height: 'auto', lineHeight: '37px', width: '100%', whiteSpace: 'pre-wrap', wordBreak: 'break-all' }}>
                                            {item.elementTypeCode == "Labelarea" ? (
                                                item.IEMRTempElementCode == "DE05.01.025.00" ? (
                                                    <div>
                                                        {this.state.diagnoseTempObj && this.state.diagnoseTempObj.map((data, index) => {
                                                            return (
                                                                <div>{index + 1}、{data.ICDDesc + ";"} {data.TCMSyndrome && data.TCMSyndrome.map((item, index) => {
                                                                    return (
                                                                        <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{item.syndromeDesc}</div>
                                                                    )
                                                                })}</div>
                                                            )

                                                        })}
                                                    </div>
                                                ) : (<div>
                                                    {this.state.orderTempPresc && this.state.orderTempPresc.map((data, index) => {

                                                        if (data.prescTypeCode == "PT") {
                                                            return (
                                                                <div>{index + 1}、{data.ordDesc} &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{data.spec}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{data.qtyUomStr}</div>
                                                            )
                                                        } else {
                                                            return (
                                                                <div>
                                                                    {data.comPresc && data.comPresc.map((med, index) => {
                                                                        return (
                                                                            <div>{index + 1}、{med.comPrinciple} &nbsp;&nbsp; {med.ordDesc} &nbsp;&nbsp; {med.doseUnitStr}</div>
                                                                        )

                                                                    })}
                                                                    <div>用法 ：{data.comPresc[0].durStr} &nbsp;&nbsp; {data.comPresc[0].frequenceDesc}   &nbsp;&nbsp; {data.prescDoseQty}   &nbsp;&nbsp; {data.prescUsageExplainDesc}  &nbsp;&nbsp; {data.comPresc[0].usageDesc}</div>
                                                                </div>
                                                            )

                                                        }

                                                    })}
                                                </div>)
                                            ) : (
                                                <div style={{ border: '0px', height: 'auto' }} >{item.IEMRTempElementData ? item.IEMRTempElementData : item.IEMRMoudleElementData}</div>
                                            )}
                                        </div>
                                    </div>
                                )
                            })}
                        </div>
                        <div >
                            <Button style={{ height: '38px', width: '100%', background: 'dodgerblue', color: 'white', lineHeight: '38px', }}
                                disabled={this.state.disBtn == 'N'} onClick={this.exchangeTemplate}>引用此病历</Button>
                        </div>
                    </Col>
                    <Col span={this.state.medicalRecordShow == "Y" ? 13 : 17} style={{ height: '100%' }}>
                        <div style={{ height: '49px', width: '100%', borderBottom: '1px solid #eeeeee', paddingTop: '7px', paddingRight: '30px' }}>
                            <Button type="primary" style={{ marginRight: '5px' }} onClick={this.exchangeTemplate.bind(this, "Y")}>清空</Button>
                            <Button type="primary" style={{ marginRight: '5px', }} onClick={this.saveRecord} disabled={this.state.disBtn == 'N'}>保存</Button>
                            <Button type="primary" style={{ marginRight: '5px', display: this.state.printShow == "Y" ? '' : 'none' }} onClick={this.printRecord}>打印</Button>

                            {/* <Button type="primary" style={{ marginRight: '5px', display:this.state.printShow == "Y"?'':'' }} onClick={this.printRecord}>打印</Button> */}
                            <Button type="primary" style={{ marginRight: '5px' }} onClick={this.showTemplateModal}>保存模板</Button>
                        </div>
                        <Form {...layout} style={{ marginTop: '10px', overflowY: 'auto', height: 'calc(100vh - 246px)' }} name="template">
                            {this.state.basicData.map((item, index) => {
                                if (item.elementTypeCode == "Text" || item.TempElementTypeCode == "Text") {
                                    return (
                                        <Form.Item className="FormItemDesc" label={item.IEMRTempElementDesc} style={{ marginBottom: '20px' }} key={item.IEMRTempElementCode}>
                                            {getFieldDecorator("ID" + item.IEMRTempElementID, {
                                                // initialValue: item.IEMRTempElementCode == "patBaseInfo" ? (((this.state.baseInfo) && (this.state.baseInfo.hasOwnProperty('patName')) ? (this.state.baseInfo.patName + "  " + this.state.baseInfo.patSexDesc + " " + this.state.baseInfo.patAge) : '')) : (item.IEMRTempElementData ? item.IEMRTempElementData : item.IEMRMoudleElementData),
                                                initialValue: item.IEMRTempElementData,
                                                rules: [{
                                                    required: this.state.writeMust == "Y" ? (item.IEMRTempElementRequired == "Y" ? true : false) : false,
                                                    message: '请填写完整信息'
                                                }],
                                            })(
                                                <Input disabled={item.IEMRTempElementCode == "patBaseInfo" ? true : false} onChange={this.updateFlag} />
                                            )}
                                        </Form.Item>
                                    )
                                }

                                if (item.elementTypeCode == "Input" || item.TempElementTypeCode == "Input") {
                                    return (
                                        <div>
                                            <div style={{ display: 'flex', justifyContent: 'flex-end', width: '100%', paddingBottom: '7px', paddingRight: '30px' }}>
                                                <span type="primary" style={{ marginRight: '5px', color: '#0079FE', cursor: 'pointer' }} onClick={this.showModal.bind(this, item.IEMRTempElementID, item)}>从知识库选择</span>
                                                <span type="primary" style={{ marginRight: '5px', color: '#0079FE', cursor: 'pointer' }} onClick={this.showModalSave.bind(this, item.IEMRTempElementID, item)}>保存到知识库</span>
                                            </div>
                                            <Form.Item
                                                className="FormItemDesc"
                                                label={item.IEMRTempElementDesc}
                                                key={item.IEMRTempElementCode}
                                                style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-all', marginBottom: '20px' }}
                                            >
                                                {getFieldDecorator("ID" + item.IEMRTempElementID, {
                                                    initialValue: item.IEMRTempElementData,
                                                    rules: [{ required: this.state.writeMust == "Y" ? (item.IEMRTempElementRequired == "Y" ? true : false) : false, message: '请填写完整信息' }],
                                                })(
                                                    <TextArea rows={item.Height > 0 ? item.Height : 4} onChange={this.updateFlag} ></TextArea>
                                                )}
                                            </Form.Item>
                                        </div>

                                    )
                                }


                                if (item.elementTypeCode == "Labelarea" || item.TempElementTypeCode == "Labelarea") {
                                    return (
                                        <Form.Item className="FormItemDesc" label={item.IEMRTempElementDesc} style={{ marginBottom: '20px' }} key={item.IEMRTempElementCode}>
                                            {getFieldDecorator("ID" + item.IEMRTempElementID, {
                                                rules: [{ required: false, message: '' }]
                                            })(<List
                                                size="small"
                                                bordered
                                                dataSource={item.IEMRTempElementCode == "DE05.01.025.00" ? this.state.diagnoseObj.length > 0 ? ["1"] : undefined : this.state.orderPresc}
                                                renderItem={item, data => item.IEMRTempElementCode == "DE05.01.025.00" ? (
                                                    <List.Item key={data.diagnoseID}>{diagonseStr} </List.Item>
                                                ) : (data.prescTypeCode != "CM" ?
                                                    (<List.Item key={data.ordID}>
                                                        <Row style={{ width: '100%' }}>
                                                            <Col span={24}>
                                                                {data.ordDesc} &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{"共" + data.qtyUomStr}
                                                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                            </Col>
                                                            {/* <Col span={8} style={{ borderLeft: '1px solid #999999' }}>
                                                                    {data.durStr}
                                                                </Col> */}
                                                            <Col span={24} >
                                                                用法： {data.doseUnitStr + "/次"},{data.frequenceDesc},{data.usageDesc}，{"共" + data.durStr} &nbsp;&nbsp; {data.note != "" && data.note != undefined ? "(" + data.note + ")" : ""}
                                                            </Col>
                                                        </Row>
                                                        {data && data.childOrd && data.childOrd.map((item, index) => {
                                                            <Row>
                                                                <Col span={24}>
                                                                    {item.ordDesc}&nbsp;{item.spec}

                                                                </Col>
                                                                {/* <Col span={4} style={{ borderLeft: '1px solid #999999' }}>
                                                                        <div>{item.durStr}</div>
                                                                    </Col> */}
                                                                <Col span={24}>
                                                                    用法：{item.doseUnitStr + "/次"},{item.frequenceDesc},{item.usageDesc},{item.qtyUomStr} &nbsp;&nbsp;{data.note != "" && data.note != undefined ? "(" + data.note + ")" : ""}
                                                                </Col>
                                                            </Row>
                                                        })}
                                                    </List.Item>) :
                                                    (
                                                        <List.Item key={data[0] ? data[0].ordID : ""}>
                                                            {data.comPresc && data.comPresc.length > 0 && data ? (
                                                                <Row>
                                                                    {data.comPresc.map((item, index) => {
                                                                        return (

                                                                            <Col span={6}>
                                                                                {item.ordDesc}&nbsp;{item.doseUnitStr}
                                                                            </Col>


                                                                        )
                                                                    })}
                                                                    <Col span={24}>
                                                                        用法 ：{data.comPresc[0].durStr},{data.prescHerbalFormDesc},{data.comPresc[0].frequenceDesc},{data.prescDoseQty},{data.prescUsageDesc != "" ? data.prescUsageDesc + "," : ""} {data.prescCookTypeDesc != "" ? data.prescCookTypeDesc + "," : ""} {data.prescUsageExplainDesc} &nbsp;&nbsp;{data.comPresc[0].note != "" && data.comPresc[0].note != undefined ? "(" + data.comPresc[0].note + ")" : ""}
                                                                    </Col>
                                                                </Row>
                                                            ) : ""}
                                                        </List.Item>
                                                    ))
                                                }
                                            />

                                            )}
                                        </Form.Item>
                                    )
                                }


                            })}


                        </Form>
                        <Row style={{ height: '38px', paddingLeft: '10px' }}>
                            {this.state.TemplateList && this.state.TemplateList.map((data, index) => {
                                return (
                                    <Col span={4} style={{ marginLeft: '5px', height: '38px', lineHeight: '38px', textAlign: 'center', background: this.state.selectedKeys1[0] == data.id ? 'rgba(223, 238, 255, 1)' : '#999999', width: 'auto' }} onClick={this.onSelect.bind(this, data)}>{data.name}</Col>
                                )
                            })}
                        </Row>


                    </Col>
                    <Col span={4} style={{ height: '100%', display: this.state.medicalRecordShow == "Y" ? '' : 'none' }}>
                        <Card style={{ overflow: 'auto', height: '100%' }}
                            title={<span style={{ textAlign: 'center' }}>问诊详情</span>}>
                            {this.state.refuseCode == 'RR' ? null : <div style={{ marginTop: 10 }}>
                                <span style={{ color: '#999999' }}>距离取消：</span>
                                <span>{!Util.isEmpty(this.state.detailMessage) ? this.state.detailMessage.countdown : '--'}</span>
                            </div>}
                            <div style={{ marginTop: 10 }}>
                                <span style={{ color: '#999999' }}>预约时间：</span>
                                <span>{!Util.isEmpty(this.state.detailMessage) ? (this.state.detailMessage.admDate + '   ' + this.state.detailMessage.admTime) : '--'}</span>
                            </div>
                            <div style={{ marginTop: 10 }}>
                                <span style={{ color: '#999999' }}>问诊类型：</span>
                                <span>{!Util.isEmpty(this.state.detailMessage) ? this.state.detailMessage.admType : '--'}</span>
                            </div>
                            <div style={{ marginTop: 10 }}>
                                <span style={{ color: '#999999' }}>患病时长：</span>
                                <span>{!Util.isEmpty(this.state.detailMessage) ? this.state.detailMessage.illnessTime : '--'}</span>
                            </div>
                            <div style={{ marginTop: 10 }}>
                                <span style={{ color: '#999999' }}>病情描述：</span>
                                <span>{!Util.isEmpty(this.state.detailMessage) ? this.state.detailMessage.symptom : '--'}</span>
                            </div>
                            <div style={{ marginTop: 10 }}>
                                <span style={{ color: '#999999' }}>疾病描述：</span>
                                <span>{!Util.isEmpty(this.state.detailMessage) ? this.state.detailMessage.DiseaseDesc : '--'}</span>
                            </div>
                            <div style={{ marginTop: 10 }}>
                                <span style={{ color: '#999999' }}>过敏描述：</span>
                                <span>{!Util.isEmpty(this.state.detailMessage) ? this.state.detailMessage.AllergyDesc : '--'}</span>
                            </div>
                            <div style={{ marginTop: 10 }}>
                                {/* <img scr={!Util.isEmpty(this.state.detailMessage) ? this.state.detailMessage.imageAddress : ''} /> */}
                                {this.loadImageMsg()}
                            </div>
                        </Card>
                    </Col>
                </Row>
                <Modal
                    visible={this.state.visible}
                    title='图片预览' maskClosable={false}
                    onCancel={this.handleClose}
                    imageSource={this.state.imageSource}
                    firstIndex={this.state.firstIndex}
                    bodyStyle={{ padding: 5, overflow: 'auto', maxHeight: '700px', maxWidth: '700px', minHeight: 500 }}
                    footer={<div>
                        <Icon type="zoom-in" style={{ fontSize: '24px', cursor: 'pointer' }} onClick={this.showbig} title='放大' />
                        <Icon type="zoom-out" style={{ marginLeft: 10, fontSize: '24px', cursor: 'pointer' }} onClick={this.showmin} title='缩小' />
                        <Icon type='reload' style={{ marginLeft: 10, fontSize: '24px', cursor: 'pointer' }} onClick={this.rotateright} title='旋转' />
                        <a style={{ color: 'inherit' }} href={this.state.imgPath} target="_blank"><Icon type='download' style={{ marginLeft: 10, fontSize: '24px', cursor: 'pointer' }} title='下载' /></a>
                    </div>}
                    className="crc-modal"
                >
                    <div className="crc-m-content">
                        <img src={this.state.imageSource[this.state.f]} className="imgstyle" alt="" style={{
                            width: '100%', cursor: 'pointer',
                            transform: "translate(-50% ,0%) rotate(" + this.state.rotaRight + "deg) scale(" + this.state.SS + "," + this.state.SS + ")"
                        }}
                            ref='imgstyle' />
                        <div style={{ position: 'absolute', top: '50%', left: 10, zIndex: 20, cursor: 'pointer' }}
                            onClick={this.leftshow.bind(this)}>
                            <img src={leftImg} />
                        </div>
                        <div style={{ position: 'absolute', top: '50%', right: 10, zIndex: 20, cursor: 'pointer' }}
                            onClick={this.rightshow.bind(this)}>
                            <img src={rightImg} />
                        </div>
                    </div>
                </Modal>



                <Modal
                    visible={this.state.showTemplate}
                    title='保存模板' maskClosable={false}
                    onCancel={this.closeTemplate}
                    className="crc-modal"
                    onOk={this.saveTemplate}
                >
                    <Row>
                        <Form>
                            <Col span={24}>
                                <Form.Item label="模板级别" key="templateType">
                                    {getFieldDecorator("templateType", {
                                        initialValue: "",
                                        rules: [{ required: true, message: '请填写完整的信息' }],
                                    })(
                                        <Radio.Group>
                                            {templateTypeList}
                                        </Radio.Group>
                                    )}
                                </Form.Item>
                            </Col>
                            <Col span={24}>
                                <Form.Item label="模板名称" key="templateName">
                                    {getFieldDecorator("templateName", {
                                        initialValue: "",
                                        rules: [{ required: true, message: '请填写完整的信息' }],
                                    })(
                                        <Input />
                                    )}
                                </Form.Item>
                            </Col>
                            <Col span={12}>
                                <Form.Item label="生效日期" key="haveDate">
                                    {getFieldDecorator("haveDate", {
                                        initialValue: moment(),
                                        rules: [{ required: true, message: '请填写完整的信息' }],
                                    })(
                                        <DatePicker>
                                        </DatePicker>
                                    )}
                                </Form.Item>
                            </Col>
                            <Col span={12}>
                                <Form.Item label="所属目录" key="behaveCat">
                                    {getFieldDecorator("behaveCat", {
                                        initialValue: "",
                                        rules: [{ required: false, message: '' }],
                                    })(
                                        <Select
                                            showSearch
                                            optionFilterProp="children"
                                            onSelect={this.changeCatName}
                                        >
                                            {vatRecordArr}
                                        </Select>
                                    )}
                                </Form.Item>
                            </Col>
                            <Col span={12}>
                                <Form.Item label="失效日期" key="notDate">
                                    {getFieldDecorator("notDate", {
                                        initialValue: "",
                                        rules: [{ required: false, message: '' }],
                                    })(
                                        <DatePicker >
                                        </DatePicker>
                                    )}
                                </Form.Item>
                            </Col>

                        </Form>
                    </Row>
                </Modal>

                <Modal
                    visible={this.state.visibleMedical}
                    title='从知识库选择' maskClosable={false}
                    onOk={this.handleOk}
                    onCancel={this.handleCancel}
                    className="modalEmp"
                    width="50%"
                    height="600px"
                    okText="引用知识库"
                    cancelText="取消"
                >
                    <Row>
                        <div style={{ paddingRight: '6px', position: 'relative' }}>
                            <Col span={9}>
                                <Card
                                    size="small"
                                    title={<div className="card-title-left-icon"><div></div>
                                        查找知识库</div>}
                                    className="medical-advice-listTabel"
                                >
                                    <div style={{ height: '400px', maxHeight: '400px', overflow: 'auto' }}>
                                        <div>
                                            <Row style={{ margin: '12px 0 24px 0' }}>
                                                <Col span={24} style={{ marginRight: '20px' }}>
                                                    <Input
                                                        placeholder="请输入名称查找知识库"
                                                        onPressEnter={this.handleQuery}
                                                        value={this.state.nameInput}
                                                        onChange={this.handleNameInput}

                                                    />
                                                </Col>
                                            </Row>
                                            <Row>
                                                <div className="card-title-left-icon"><div></div>知识库列表</div>
                                            </Row>
                                            <Table
                                                columns={this.columns}
                                                dataSource={tableData}
                                                // scroll={{ y: store.getState().tableHeight.y + 40 }}
                                                pagination={false}
                                                onRow={this.tableClickRow}
                                                rowKey={(row) => {
                                                    return row.id
                                                }}
                                                rowClassName={this.setRowClassName}
                                                defaultExpandedRowKeys={['0main']}
                                            />
                                        </div>
                                    </div>
                                    <div style={{ width: '6px', background: 'rgba(240, 242, 245, 1)', position: 'absolute', top: 0, right: 0, height: '100%' }}></div>
                                </Card>
                            </Col>
                        </div>
                        <Col
                            span={15}

                        >
                            <Card
                                size="small"
                                title={<div className="card-title-left-icon"><div></div>知识库内容</div>}
                                className="medical-advice-listTabel"
                            >
                                <div style={{ height: '400px', maxHeight: '400px', overflow: 'auto' }}>
                                    <TextArea rows={17} value={this.state.content1} disabled />
                                </div>
                            </Card>
                        </Col>
                    </Row>
                </Modal>



                <Modal
                    visible={this.state.visibleSave}
                    title='保存到知识库' maskClosable={false}
                    onOk={this.handleOkSave}
                    onCancel={this.onCancel}
                    className="modalEmp"
                    width="30%"
                    height="600px"
                >
                    <div style={{ width: '100%' }}>
                        <Form>
                            {/* <Row gutter={24}>
                                <Col span={24}>
                                    <Form.Item label="知识库名称"   {...formItemInput}>
                                        {getFieldDecorator('title', {
                                            initialValue: MedicalInfo.title ? MedicalInfo.title : '',
                                            rules: [{ required: true, message: '名称不能为空' }]
                                        })(
                                            <Input style={{ width: '100%' }} placeholder="请输入" allowClear />
                                        )}
                                    </Form.Item>
                                </Col>
                            </Row> */}
                            <Row gutter={24}>
                                <Col span={24}>
                                    <Form.Item label="知识库名称"   {...formItemInput}>
                                        {getFieldDecorator('content', {
                                            initialValue: MedicalInfo.content ? MedicalInfo.content : '',
                                            rules: [{ required: true, message: '知识库名称不能为空' }]
                                        })(
                                            <Input style={{ width: '100%' }} placeholder="请输入" allowClear />
                                        )}
                                    </Form.Item>
                                </Col>
                            </Row>
                            <Row gutter={24}>
                                <Col span={12}>
                                    <Form.Item label="生效日期："   {...formItemDatePicker}>
                                        {getFieldDecorator('startDate', {
                                            initialValue: MedicalInfo.startDate ? moment(MedicalInfo.startDate, 'YYYY-MM-DD') : moment(),
                                            rules: [{ required: true, message: '生效日期不能为空' }]
                                        })(
                                            <DatePicker style={{ width: '100%' }} format="YYYY-MM-DD" allowClear />
                                        )}
                                    </Form.Item>
                                </Col>
                                <Col span={12}>
                                    <Form.Item label="失效日期："   {...formItemDatePicker}>
                                        {getFieldDecorator('stopDate', {
                                            initialValue: MedicalInfo.stopDate ? moment(MedicalInfo.stopDate, 'YYYY-MM-DD') : undefined,
                                        })(
                                            <DatePicker style={{ width: '100%' }} format="YYYY-MM-DD" allowClear />
                                        )}
                                    </Form.Item>
                                </Col>
                            </Row>
                        </Form>
                    </div>
                </Modal>


            </div>
        )
    }
}
export default Form.create()(MedicalRecord); 